/**
 *  <Java Class>
 *   <Class to hadler the files created in the IDE.>
 *
 *
 *   Copyright (C) 2011  Fernando Gil
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *   The following additional terms will apply to the software provieded with
 *   this file.
 *      1. Preserve the original authors’ names.
 *      2. Documenting all contributions and specify the contributor's name,
 *         the date of the contribution and some email to future contact.
 *
 *   @author  Fernando Gil
 *   @mail    lobho.gil@gmail.com
 *   @company Development Solutions (DS) Software
 *   @date    18-oct-2011 21:26:31
 *   @modify  18-oct-2011 21:26:31
 *   @by      lobho
 *   @see     License GNU GPL v3  (/lic/GNU_GPLv3_EN)
 *   @see     Additional Terms    Point 7.1 on License (/lic/GNU_GPLv3_EN)
 *   @note   Replicate this header in all classes.
 *
 */

package org.dss.gil.util;

import java.awt.Component;
import java.util.HashMap;
import org.dss.gil.view.TablePanel;
import org.dss.gil.view.TextPanel;


public class FilesHandler {

    private HashMap <String,Component> hsm_map;

    /*********************************************************************
     ********************* S I N G L E T O N *****************************
     *********************************************************************/
    private static FilesHandler INSTANCE = null;

    private synchronized static void createInstance() {
        if (INSTANCE == null)
            INSTANCE = new FilesHandler();
    }

    public static FilesHandler getInstance() {
        if (INSTANCE == null)
            createInstance();
        return INSTANCE;
    }

    // Private constructor suppresses
    private FilesHandler() {
        hsm_map = new HashMap();
    }

    /*********************************************************************
     ********************** M E T H O D S ********************************
     *********************************************************************/

    public int getMapSize(){
        return this.hsm_map.size();
    }

    public void put(String key, TablePanel tbp_table) {
        this.hsm_map.put(key, tbp_table);
    }

    public void put(String key, TextPanel txp_Text) {
        this.hsm_map.put(key, txp_Text);
    }
    
    public void remove(String key){
        this.hsm_map.remove(key);
    }

    public boolean contains(String absolutePath) {
        return this.hsm_map.containsKey(absolutePath);
    }

    public Component getComponent(String absolutePath) {
        return this.hsm_map.get(absolutePath);
    }



}
